package org.finesys.common.file.client.oss;


import org.finesys.common.file.client.FileTemplate;
import org.finesys.common.file.client.oss.http.OssEndPoint;
import org.finesys.common.file.client.oss.service.OssFileTemplate;
import org.finesys.common.file.properties.FileProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import lombok.AllArgsConstructor;

/**
 * 云服务存储处理
 * 亚马逊云服务存储
 */
@AllArgsConstructor
@Configuration
public class OssAutoConfiguration {

    private final FileProperties fileProperties;



    @Bean
    @ConditionalOnMissingBean(OssFileTemplate.class)
    @ConditionalOnProperty(value = "file.oss.enable", havingValue = "true")
    public FileTemplate ossFileTemplate() {
        return new OssFileTemplate(fileProperties);
    }

    @Bean
    @ConditionalOnMissingBean(OssEndPoint.class)
    @ConditionalOnProperty(value = "file.oss.info", havingValue = "true")
    public OssEndPoint ossEndPoint(OssFileTemplate ossFileTemplate) {
        return new OssEndPoint(ossFileTemplate);
    }

}
